package com.central.modules.job.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.central.modules.job.dao.ScheduleJobLogDao;
import com.central.modules.job.entity.ScheduleJobLogEntity;
import com.central.modules.job.model.ScheduleJobLogQueryBean;
import com.central.modules.job.service.ScheduleJobLogService;
import org.springframework.stereotype.Service;

@Service
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> implements ScheduleJobLogService {

	@Override
	public IPage<ScheduleJobLogEntity> pageSearch(ScheduleJobLogQueryBean queryBean) {
		Page<ScheduleJobLogEntity> page = new Page<>(queryBean.getPageStart(), queryBean.getPageSize());
		LambdaQueryWrapper<ScheduleJobLogEntity> queryWrapper = new LambdaQueryWrapper<ScheduleJobLogEntity>();
		queryWrapper.orderByAsc(ScheduleJobLogEntity::getCreateDate);
		queryWrapper.eq(StrUtil.isNotBlank(queryBean.getJobId()), ScheduleJobLogEntity::getJobId, queryBean.getJobId());
		return this.page(page, queryWrapper);
	}

	@Override
	public ScheduleJobLogEntity get(Long id) {
		return this.getById(id);
	}

}